home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / CDTools / GoFetch! / arexx / Olivier_Fabre / AminetFetch.rexx < prev   
OS/2 REXX Batch file  |  1999-12-10  |  4KB  |  154 lines

  1. /*
  2. ** $VER: AminetFetch.rexx 1.1 (10.12.1999) by Olivier Fabre <off@free.fr>
  3. **
  4. ** Insert all files listed in an Aminet INDEX or RECENT file
  5. ** into GoFetch! profiles list.
  6. ** GoFetch! will be run if necessary.
  7. **
  8. ** Template :
  9. **   FILE=F,GETREADMES=GR/T,LOCALDIRS=LDS/T,AMINETSERVER=AS/K,AMINETPATH=AP/K,
  10. **    LOCALDIR=LD/K,GOFETCH=GF/K
  11. **
  12. **   FILE
  13. **       Name of the file containing the list of files to be
  14. **       downloaded from Aminet (default : "AMINET_EXTRACTED").
  15. **
  16. **       Format of this file :
  17. **         <filename> <dir/subdir> <whatever>
  18. **         ...
  19. **
  20. **   GETREADMES/T
  21. **       YES/ON : Download readme files (default).
  22. **       NO/OFF : Download only the main file.
  23. **
  24. **   LOCALDIRS/T
  25. **       YES/ON : Recreate the Aminet tree locally (default).
  26. **       NO/OFF : Put all files in the same directory (LocalDir).
  27. **
  28. **   AMINETSERVER/K
  29. **       Your favourite Aminet server (default : "de.aminet.net").
  30. **
  31. **   AMINETPATH/K
  32. **       Path to Aminet on the server (default : "/pub/aminet/").
  33. **       This shouldn't need to be changed.
  34. **
  35. **   LOCALDIR/K
  36. **       Where to put the downloaded files (default : "DOWNLOAD:").
  37. **
  38. **   GOFETCH/K
  39. **       GoFetch! location (default : "NET:GoFetch!/GoFetch!").
  40. **
  41. **
  42. ** Required :
  43. **   RexxDOSSupport.library (Copyright (C) 1994-1997 by hartmut Goebel)
  44. **   (Aminet:util/rexx/rexxdossupport.lha)
  45. */
  46.  
  47. /**************************************************************************/
  48. /* Edit the following lines to suit your tastes                           */
  49. /* These are the default options; they are overridden by the command line */
  50. /**************************************************************************/
  51.  
  52. File         = "AMINET_EXTRACTED"        /* The Aminet filename list filename :) */
  53. AminetServer = "de.aminet.net"            /* Your favourite Aminet server */
  54. AminetPath   = "/pub/aminet/"                /* Path to Aminet on the server */
  55. LocalDir     = "DOWNLOAD:"                    /* Where to put the downloaded files */
  56. LocalDirs    = 1            /* Set to 1 to recreate the Aminet tree locally, 0 otherwise */
  57. GetReadmes   = 1            /* Set to 1 to download the readme files, 0 otherwise */
  58. GoFetch      = "NET:GoFetch!/GoFetch!"    /* GoFetch! location */
  59.  
  60. /********************************/
  61. /* Do not change anything below */
  62. /********************************/
  63.  
  64.  
  65. SAY "AminetFetch.rexx 1.1 (10.12.1999) by Olivier Fabre <off@free.fr>"
  66.  
  67. IF ~SHOW('L', 'rexxdossupport.library') THEN DO
  68.     IF ~ADDLIB('rexxdossupport.library', 0, -30, 2) THEN DO
  69.         SAY "RexxDOSSupport.library not available, go to hell :->"
  70.         EXIT 20
  71.     END
  72. END
  73.  
  74. PARSE ARG args
  75.  
  76. template = "FILE=F,GETREADMES=GR/T,LOCALDIRS=LDS/T,AMINETSERVER=AS/K,AMINETPATH=AP/K,LOCALDIR=LD/K,GOFETCH=GF/K"
  77.  
  78. IF ~ReadArgs(args,template) THEN DO
  79.     SAY "Error parsing arguments."
  80.     SAY "Template :" template
  81.     EXIT 20
  82. END
  83.  
  84. IF ~EXISTS( LocalDir ) THEN DO
  85.     SAY 'Error : The download directory "'LocalDir'" does not exist !'
  86.     EXIT 20
  87. END
  88.  
  89. IF ~OPEN("f",file,"R") THEN DO
  90.     SAY 'Error : Could not open file "'file'" for reading.'
  91.     EXIT 20
  92. END
  93.  
  94. IF ~SHOW( "P", "GOFETCH" ) THEN DO
  95.     SHELL COMMAND "Run" GoFetch
  96.     SHELL COMMAND "WaitForPort GOFETCH"
  97.     IF rc = 5 THEN DO
  98.         SAY "Unable to run GoFetch!"
  99.         EXIT 20
  100.     END
  101. END
  102.  
  103. IF LocalDirs = 0 THEN DO
  104.     localpath = LocalDir
  105.     IF (RIGHT( LocalDir, 1 ) ~= ":") & (RIGHT( LocalDir, 1 ) ~= "/") THEN DO
  106.         localpath = localpath"/"
  107.     END
  108. END
  109.  
  110. ADDRESS GOFETCH
  111.  
  112. DO WHILE ~EOF("f")
  113.  
  114.     l = READLN( "f" )
  115.     IF l ~= "" THEN DO
  116.  
  117.         p = POS( " ", l )
  118.         filename = LEFT( l, p-1 )
  119.  
  120.         l = STRIP( SUBSTR( l, p ) )
  121.         p = POS( " ", l )
  122.         filepath = LEFT( l, p-1 )
  123.  
  124.         IF LocalDirs = 1 THEN DO
  125.             localpath = AddPart( LocalDir, filepath )
  126.             IF ~EXISTS( localpath ) THEN DO
  127.                 SAY "Creating the directory :" localpath
  128.                 p = LASTPOS( "/", localpath )
  129.                 IF p>1 THEN DO
  130.                     IF ~EXISTS( LEFT( localpath, p-1 ) ) THEN DO
  131.                         MakeDir( LEFT( localpath, p-1 ) )
  132.                     END
  133.                 END
  134.                 MakeDir( localpath )
  135.             END
  136.             localpath = localpath"/"
  137.         END    /* IF LocalDirs */
  138.  
  139.         "ADDANONPROFILE" AminetServer 21 AddPart( AminetPath, filepath ) filename localpath
  140.  
  141.         IF GetReadmes = 1 THEN DO
  142.  
  143.             p = LASTPOS( ".", filename )
  144.             filename = LEFT( filename, p-1 ) || ".readme"
  145.             "ADDANONPROFILE" AminetServer 21 AddPart( AminetPath, filepath ) filename localpath
  146.  
  147.         END    /* IF GetReadmes */
  148.  
  149.     END    /* IF ~"" */
  150.  
  151. END    /* WHILE ~EOF */
  152.  
  153. SAY "Done."
  154.